package com.hu.zhcc.shiro.service.dingming;

import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.common.entity.PageRequest;
import com.hu.zhcc.shiro.dao.dingming.TSportsItemLibraryMapper;
import com.hu.zhcc.shiro.entity.dingming.TSportsItemLibrary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TSportsItemLibraryServiceImpl implements TSportsItemLibraryService{
    @Autowired
    private TSportsItemLibraryMapper tSportsItemLibraryMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return tSportsItemLibraryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(TSportsItemLibrary record) {
        return tSportsItemLibraryMapper.insert(record);
    }

    @Override
    public int insertSelective(TSportsItemLibrary record) {
        return tSportsItemLibraryMapper.insertSelective(record);
    }

    @Override
    public TSportsItemLibrary selectByPrimaryKey(Integer id) {
        return tSportsItemLibraryMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(TSportsItemLibrary record) {
        return tSportsItemLibraryMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(TSportsItemLibrary record) {
        return tSportsItemLibraryMapper.updateByPrimaryKey(record);
    }

    @Override
    public Page<TSportsItemLibrary> listTSportsItem(Map<String, Object> parameters, Integer offset, Integer limit) {
        int total = tSportsItemLibraryMapper.countSportsItem(parameters);
        List<TSportsItemLibrary> sportsItemLibrary = null;
        if (total > 0) {
            PageRequest pageRequest = new PageRequest(offset, limit, parameters);
            sportsItemLibrary = tSportsItemLibraryMapper.listSportsItem(pageRequest);
        }
        return new Page<TSportsItemLibrary>(total, sportsItemLibrary);
    }
}
